<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Manage Cars</title>
<Header> <jsp:include page="/Template/Header.jsp" /> </Header>
</head>
<body>
	<script>
		var toggleedit = function() {
			var mydiv = document.getElementById('editform');
			if (mydiv.style.display === 'block' || mydiv.style.display === '')
				mydiv.style.display = 'none';
			else
				mydiv.style.display = 'block'
		}
		var toggleadd = function() {
			var mydiv = document.getElementById('addform');
			if (mydiv.style.display === 'block' || mydiv.style.display === '')
				mydiv.style.display = 'none';
			else
				mydiv.style.display = 'block'
		}
	</script>
	<input type="button" id="addtbutton" value="Add" onclick="toggleadd();">
	<div id="addform" style="DISPLAY: none">
		<form class="addcar" name="frmac" action="addCar" method="post">
			<p>
				<label for="C_name">Car Name :</label> <input type="text"
					id="C_name" name="C_name" required />
			</p>
			<p>
				<label for="C_brand">Car Brand :</label> <input type="text"
					id="C_brand" name="C_brand" required />
			</p>
			<p>
				<label for="C_year">First Entry Year : </label><input type="year"
					id="C_year" name="C_year">
			</p>
			<p>
				<input type="submit" id="addcarsubmit" name="sub" value="Add">
			</p>


		</form>
	</div>
	<div id="ListCar">
		<c:forEach items="${CarList}" var="car">
			<div id="car_show_edit">
				<h2>${car.name}</h2>
				<p>${car.brand}</p>
				<ul>
					<c:forEach items="${car.historiquePosition}" var="pos">
						<li>X : ${pos.positionx} , Y: ${pos.positiony}</li>
					</c:forEach>
				</ul>
				<input type="button" id="editbutton" value="edit"
					onclick="toggleedit();">
				<div id="editform" style="DISPLAY: none">
					<form action="editCar" method="post">
						<label for="c_name">Name :</label> <input type="text" id="c_name"
							name="c_name" required /> <label for="c_brand">Brand :</label> <input
							type="text" id="c_brand" name="c_brand" required /> <label
							for="c_ney">New Entry Year :</label> <input type="text"
							id="username" name="username" required /> <input type="hidden"
							value="${car.id}" name="id"> <input type="submit"
							value="Editer">
					</form>
				</div>
				<form action="removeCar" method="post">
					<input type="submit" value="Supprimer"> <input
						type="hidden" value="${car.id}" name="id2">
				</form>
			</div>
		</c:forEach>
	</div>
</body>
</html>